#include <Arduino.h>

typedef enum {OFF,ON} float_state_e;
typedef enum {eNOT_FILL,eFILL} water_state_e;
 

// set pin numbers:
const int TopFloatPin = 7;     // the number of the Top float pin
const int LowFloatPin = 8;     // the number of the Low float pin
const int PumpPin = 5;
const int ledPin =  12;      // the number of the LED pin

// variables will change:
float_state_e TopState = OFF;         // variable for reading the Top float status
float_state_e LowState = OFF;         // variable for reading the Low float status

water_state_e  water_state = eNOT_FILL;

void start_fill(){
  digitalWrite(PumpPin, HIGH); 
  water_state  = eFILL;
  digitalWrite(ledPin, HIGH); 
}

void stop_fill(){
  digitalWrite(PumpPin, LOW); 
  water_state  = eNOT_FILL;
  digitalWrite(ledPin, LOW); 
}


void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the Top float pin as an input:
  pinMode(TopFloatPin, INPUT);     
   // initialize the Low float pin as an input:
  pinMode(LowFloatPin, INPUT); 
  pinMode(PumpPin, OUTPUT); 
  digitalWrite(PumpPin, LOW);  
}

void loop(){
  // read the state of the Top float value:
  int State = digitalRead(TopFloatPin);
  if(State == 1)
    TopState = ON;
   else
     TopState = OFF;
  // read the state of the Low float value:
  State = digitalRead(LowFloatPin);
  if(State == 1)
    LowState = ON;
   else
     LowState = OFF;
     
      if ( water_state == eNOT_FILL ){     
       if ( LowState == OFF && TopState == OFF ){
           start_fill();  
       }
     }else{
         if(TopState == ON){
           stop_fill();  
         } 
     }

}
